#pragma once

#include <QObject>
#include <osg/Referenced>
#include "corebase_global.h"
#include <QUuid>

namespace CoreBase
{
	class COREBASE_EXPORT Base : QObject, public osg::Referenced
	{
		Q_OBJECT
	public:
	   struct COREBASE_EXPORT MessageData
	   {
		  QString message;
		  Base* sender;       
		  void* userData;
	   };
	   Base(const QString& name = "base");
	protected:
	   virtual ~Base();
	public:
	   void setName(const QString& name);
	   const QString& getName() const;
	   void setId(const QString& id) { _id = id; };
	   const QString& getId() 
	   {
		   if(_id == "")
			   _id = QUuid::createUuid().toString();
		   return _id; 
	   }
	   void addSender(Base* sender);
	   void removeSender(Base* sender);
	   void sendMessage(const QString& message = "", void* data = 0);
	private:
	   QString _name;
	   QString _id;
	public slots:
		virtual void onMessage(MessageData*) {}
	signals:
	   void emitSignals(MessageData*);
	};
}